/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.action.equiposRed;

import com.mapping.DetallesRed;
import com.opensymphony.xwork2.ActionSupport;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

/**
 *
 * @author Ricardo
 */
@Namespace(value = "/")
@Action(value = "eliminarEquipoRed", results = {
    @Result(name = "success", location = "/GestionEquiposRed/resultadoEquiposRed.jsp")})
public class EliminarEquipoRed extends ActionSupport{
    private String mensaje;
    private DetallesRed detalle;
    private int idDetalleRed;
    
    @Override
    public String execute(){       
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("inventarios");
        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        tx.begin();                     
        detalle = em.getReference(DetallesRed.class,idDetalleRed);                
        em.remove(detalle);
        em.flush();
        tx.commit();
        em.close();         
        return SUCCESS;
    }

    public String getMensaje() {
        return mensaje;
    }

    public DetallesRed getDetalle() {
        return detalle;
    }

    public void setIdDetalleRed(int idDetalleRed) {
        this.idDetalleRed = idDetalleRed;
    }
        
}
